using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DirectoryController : IUIController
{
    public override void AddListener()
    {
        PanelEvent.AddListener(DirectoryPanelEvent.Find.ToString(), OnDirectoryEvent);
    }

    public override void Init()
    {
        List<DirectoryListInfo> directoryList = new List<DirectoryListInfo>();
        for (int i = 0; i < 10; i++)
        {
            DirectoryListInfo directoryListInfo = new DirectoryListInfo();
            directoryListInfo.directoryName = "Directory" + i;
            directoryListInfo.state = "Normal";
            directoryListInfo.depth = 0;
            directoryListInfo.siblingIndex = i + 0;
            directoryListInfo.childs = new List<DirectoryListInfo>();
            for (int j = 0; j < 4; j++)
            {
                DirectoryListInfo childDirectoryListInfo = new DirectoryListInfo();
                childDirectoryListInfo.directoryName = "ChildDirectory" + i + j;
                childDirectoryListInfo.state = "Normal";
                childDirectoryListInfo.siblingIndex = j + 0;
                childDirectoryListInfo.depth = 1;
                childDirectoryListInfo.childs = new List<DirectoryListInfo>();
                for (int k = 0; k < 2; k++)
                {
                    DirectoryListInfo childChildDirectoryListInfo = new DirectoryListInfo();
                    childChildDirectoryListInfo.directoryName = "ChildDirectoryChild" + i + j + k;
                    childChildDirectoryListInfo.state = "Normal";
                    childChildDirectoryListInfo.siblingIndex = k + 0;
                    childChildDirectoryListInfo.depth = 2;
                    childDirectoryListInfo.childs.Add(childChildDirectoryListInfo);
                }
                directoryListInfo.childs.Add(childDirectoryListInfo);
            }
            directoryList.Add(directoryListInfo);
        }
        CommandEvent.Invoke(DirectoryPanelEvent.Generate.ToString(), directoryList);
    }

    public void OnDirectoryEvent(params object[] args)
    {
        DirectoryListInfo directoryListInfo = (DirectoryListInfo)args[0];
        bool isOn = (bool)args[1];
        bool isCheckClick = (bool)args[2];

        Debug.Log("Directory: " + directoryListInfo.directoryName + " state:" + directoryListInfo.state);
        Debug.Log("isOn: " + isOn + " isCheckClick: " + isCheckClick);
    }
}
